package com.ruijixiang.leetcode.weekly.leetcode2024.leetcode20240901;

import java.util.PriorityQueue;

public class leetcode3275 {
    public int[] resultsArray(int[][] queries,int k){
        PriorityQueue<Integer> pq=new PriorityQueue<>((a,b)->(b-a));// 构建大根堆
        int[] res=new int[queries.length];
        for(int i=0;i<queries.length;i++){
            pq.offer(Math.abs(queries[i][0])+Math.abs(queries[i][1]));
            if(pq.size()>k){
                pq.poll();
            }
            res[i]=pq.size()==k ? pq.peek() : -1;
        }
        return res;
    }
}
